﻿using System;

namespace zielonka.co.uk.extensions.Generic.Class.generic
{
    // Description:	converts one type to another
    /*
        var age = "28";
        var intAge = age.To<int>();
        var doubleAge = intAge.To<double>();
        var decimalAge = doubleAge.To<decimal>();
      */
    public static partial class GenericExtensions
    {
        public static T To<T>(this IConvertible value)
        {
            try
            {
                return (T)Convert.ChangeType(value, typeof(T));
            }
            catch
            {
                return default(T);
            }
        }
    }
}
